﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace TVShow.Framework
{
  public class Keyboard : PluginBase, TVShow.Framework.IKeyboardHandler
  {
    Dictionary<string, string> KeyMap = new Dictionary<string, string>();
    public override void LoadPlugin(DisplayManager Display) {
      base.LoadPlugin(Display);
      Display.Keyboard = this;

      KeyMap = INIfile.GetValues("Keyboard");
    }

    public void KeyDown(KeyEventArgs e) {
      string KeyCode = e.KeyCode.ToString();
      if (KeyMap.ContainsKey(KeyCode)) {
        TVSMessage.Send("action",KeyMap[KeyCode]);
      }
      else {
        // Log the key and send it to the test rig so the user can 
        // map it.
        System.Diagnostics.Debug.WriteLine("Unknown Key: " + KeyCode);
        TVSMessage.Send("Unknown Key", KeyCode);
      }
    }

    public override void ProcessMessage(TVSMessage Event) {
    }

    public void KeyUp(KeyEventArgs e) {
    }

  }
}
